package cn.edu.ctbu.datajpa_02.repository;

import cn.edu.ctbu.datajpa_02.domain.Teacher;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface TeacherRepository extends JpaRepository<Teacher, Integer> {

    @Query("select t from tb_teacher t where substring(t.no,1,4) ="+
            "(select substring(MAX(t1.no),1,4)from tb_teacher t1 group by substring(t1.no,1,4)having count(*)>1)")
    List<Teacher> getLatestJoinedTeachers();

}
